#!/usr/bin/python
#-*- coding:utf-8 -*-

#判断设备的状态，返回是否发送升级命令
import datetime
class Controll():
	"""docstring for Judge"""
	#记录设备的状态 
	#	devs={
	#dev1:{"devtype":"","last_version":"","statu":"","lasttime":"","tar_version":"","push_time":""},
	#dev2:{"devtype":"","last_version":"","statu":"","lasttime":"","tar_version":"","push_time":""}
	#}
	devs={}

	def __init__(self, devs):
		super(Controll, self).__init__()
		self.devs = devs

	def suc_judge(devid,version,vertime):
		#获取本次上报的设备状态
		dev = devs[devid]
		now = str(time.now())
		#判断是否还未开始推送
		if tar_version == "":
			return True
			break
		elif:
        	#判断是否是升级成功
			if version == tar_version:
				uptime = time.now()-dev[push_time]
				print(now+"===设备%s成功升级到版本%s,用时%s")%{devid,dev[tar_version],uptime} > upgrade.log
				return True
			elif:
				print(now+"===设备%s升级版本%s失败！！")%{devid,dev[tar_version]} > upgrade.log
				return False
		
	def push_judge(devid,version,vertime):
		#获取本次上报的设备状态
		dev = devs[devid]
		now = datetime.datetime.now()
		#判断上报时间，按照平台的推送周期15min算
		if (vertime - lasttime ) < 15 min: #时间怎么写？
			#更新最近上报时间
			print(now+"===版本上报过快，本次不推送") > upgrade.log
			return False
			
